<!-- 右侧工具面板 -->
<template>
  <div class="panel-container">
    <panel-global v-if="!current"></panel-global>
    <aside-background v-if="current && (current.type === typeConstants.BACKGROUND)"></aside-background>
    <!-- 这里通过v-show缓存 -->
    <panel-font v-show="current && (current.type === typeConstants.FONT)"></panel-font>
  </div>
</template>

<script>
import {
  PanelGlobal,
  PanelFont
} from './components'
import { AsideBackground } from '../aside/components'
import { mapState } from 'vuex'
import { STORE_NAMESPACE, typeConstants } from '../../config'
export default {
  name: 'DesignPanel',
  components: {
    PanelGlobal,
    PanelFont,
    AsideBackground
  },
  data () {
    return {
      typeConstants: { ...typeConstants }
    }
  },
  computed: {
    ...mapState({
      current: state => state[STORE_NAMESPACE].current
    })
  }
}
</script>

<style lang="less" scoped>
.panel-container {
  width: 260px;
  background: #fff;
  position: relative;
  box-shadow: -3px 0 4px rgba(0, 0, 0, .1);
  & ::v-deep .panel-template {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  & ::v-deep .title {
    font-weight: bold;
    padding: 10px;
    line-height: 1;
    border-bottom: 1px solid #f1f1f1;
    font-size: 13px;
  }
  & ::v-deep .content {
    flex: 1;
    padding: 10px;
    overflow: auto;
    .block {
      padding-bottom: 20px;
      .dt { color: #999; padding-bottom: 10px;}
      .submit {
        padding-top: 10px;
        .el-button{ width: 100%;}
      }
      dl {
        display: flex; align-items: center; flex: 1;
        dt { padding: 0 10px; min-width: 5em; text-align: right;}
        dd { flex: 1;}
      }
    }
    .panel-row {
      display: flex;
      border: 1px solid #ddd;
      padding: 8px 0;
      border-radius: 3px;
      margin-bottom: 10px;
      &:last-child {
        margin-bottom: 0;
      }
      li{
        flex: 1; text-align: center; border-right: 1px solid #ddd;
        &:last-child{ border-right: 0;}
      }
      .el-button {
        border: 0;
        padding: 0;
        background: transparent;
        height: 22px;
        overflow: hidden;
        color: #000;
        &.active{ color: #e23738;}
        &.is-disabled{ color: #C0C4CC;}
      }
    }
  }
}
</style>